package com.spa.infrastructure.repository.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.yulichang.base.MPJBaseServiceImpl;
import com.spa.infrastructure.repository.mapper.DouYinOauthMapper;
import com.spa.infrastructure.repository.po.DouyinOauthPO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
@Slf4j
public class DouYinOauthRepositoryService extends MPJBaseServiceImpl<DouYinOauthMapper, DouyinOauthPO> {

    @Resource
    private DouYinOauthMapper douYinOauthMapper;

    public Long addDouYinAccount(DouyinOauthPO po) {
        douYinOauthMapper.insert(po);
        return po.getId();
    }

    public DouyinOauthPO getByOpenId(String openId) {
        QueryWrapper<DouyinOauthPO> wrapper = new QueryWrapper<>();
        wrapper.eq("open_id", openId);
        return douYinOauthMapper.selectOne(wrapper);
    }

}
